<style type="text/css">
    .layui-table-body {
        overflow-x: auto;
    }

    .layui-table-cell {
        font-size: 12px;
    }
</style>
<div class="page-toolbar">
    <div class="page-filter fr">
        <form class="layui-form layui-form-pane" action="{:url()}" id="hisiSearch" method="get">
            <div class="layui-form-item">
                <label class="layui-form-label">搜索</label>
                <div class="layui-input-inline">
                    <input type="text" name="keyword" value="" lay-verify="required" placeholder="名称" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
        </form>
    </div>
    <div class="layui-btn-group fl">
        <a href="{:url('createCategories')}" class="layui-btn layui-btn-primary layui-icon layui-icon-add-circle-fine">&nbsp;添加</a>
        <a data-href="{:url('status?table=group_categories&val=1')}"
           class="layui-btn layui-btn-primary j-page-btns layui-icon layui-icon-play" data-table="dataTable">
            &nbsp;启用</a>
        <a data-href="{:url('status?table=group_categories&val=0')}"
           class="layui-btn layui-btn-primary j-page-btns layui-icon layui-icon-pause" data-table="dataTable">
            &nbsp;禁用</a>
        <a data-href="{:url('del?table=group_categories')}"
           class="layui-btn layui-btn-primary j-page-btns confirm layui-icon layui-icon-close red">&nbsp;删除</a>
    </div>
</div>
<form id="pageListForm">
    <div class="layui-form">
        <table id="dataTable"></table>
        <script type="text/html" title="排序模板" id="sortTpl">
            <input type="text" class="layui-input j-ajax-input input-sort" onkeyup="value=value.replace(/[^\d]/g,'')" value="{{ d.sort }}" data-value="{{ d.sort }}" data-href="{:url('sort')}?table=group_categories&id={{ d.id }}">
        </script>
        <script type="text/html" id="statusTpl">
            <input type="checkbox" name="status" value="{{ d.status }}" lay-skin="switch" lay-filter="switchStatus" lay-text="正常|关闭" {{ d.status == 1 ? 'checked' : '' }} data-href="{:url('status')}?table=users&id={{ d.id }}">
        </script>
        <script type="text/html" title="操作按钮模板" id="buttonTpl">
            <!--<a href="{:url('view')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-normal">查看</a>--><a href="{:url('edit')}?id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-normal">修改</a><a href="{:url('status')}?table=group_categories&id={{ d.id }}" class="layui-btn layui-btn-xs layui-btn-danger j-tr-del">删除</a>
        </script>
    </div>
</form>
{include file="block/layui" /}
<script type="text/javascript">
    layui.use(['table'], function () {
        var table = layui.table;
        table.render({
            elem: '#dataTable'
            , url: '{:url()}' //数据接口
            , page: true //开启分页
            , limit: 20
            , text: {
                none: '暂无相关数据'
            }
            , cols: [[ //表头
                {type: 'checkbox'}
                , {field: 'id', title: '分类id', width: 120}
                , {field: 'name', title: '分类名称'}
                , {
                    field: 'sort', title: '排序', width: 120, templet: '#sortTpl'
                }
                , {field: 'status', title: '显示状态', width: 100, templet: '#statusTpl'}
                , {title: '操作', width: 220, templet: '#buttonTpl'}
            ]]
        });
    });
</script>